/*
 * @Author: hanxin 
 * @Date: 2021-08-12 17:30:40 
 * @Last Modified by: hanxin
 * @Last Modified time: 2021-08-12 17:35:28
 * 管理与客户端通讯的线程类
 */
package ServerService;

import java.util.Hashtable;
import java.util.Iterator;

public class manageClientThreads {
    public static Hashtable<String, serverConnectClientThread> hashtable = new Hashtable<>();
 
    /**
     * 线程加入hash集合方法
     * @param uid
     * @param thread
     */
    public static void Threadjoin(String uid, serverConnectClientThread thread) {

        hashtable.put(uid, thread);
    }

    /**
     * 返回指定线程方法
     * @param uid
     * @return
     */
    public static serverConnectClientThread returnthread(String uid) {
        return hashtable.get(uid);
    }
    /**
     * 遍历线程集合取得所有用户的uid
     * @return
     */
    public static String retrun_Online_List() {
        Iterator<String> iterator = hashtable.keySet().iterator();
        String onlinelist = "";
        while (iterator.hasNext()) {
            onlinelist += iterator.next().toString() + " ";
        }
        return onlinelist;
    }
    /**
     * 移除指定的线程
     * @param uid
     */
    public static void removeThread(String uid) {
        hashtable.remove(uid);
    }

}
